package com.woniu.adminservice.util;

import java.util.Calendar;
import java.util.Date;
/**
*@Author:huangjing
*@Description: 获取前几天的日期，并将时分秒清零，用于数据库查询
 * @param :time 传入之前的第几天
*@Date: 21:39 2020/3/23
*/
public class DateUtil {
    public static Date getTimeOnNow(int time){
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR)-time);
        calendar.set(Calendar.HOUR_OF_DAY,0);
        calendar.set(Calendar.MINUTE,0);
        calendar.set(Calendar.SECOND,0);
        Date date = calendar.getTime();

        return date;
    }
}
